<?php
	
	/* ------ Config Start ------ */
	$outtime=10*60;
	/* ------ Config End ------ */
	set_time_limit(0);
	
	echo "/*----------------------------------------*/\n";
	echo "/*	Welcome to D5Power Engine	  */\n";
	echo "/*	Version v0.1			  */\n";
	echo "/*	D5Power Studio Build in 08-11-25  */\n";
	echo "/*----------------------------------------*/\n";
	
	echo "\nNow server started.\n";
	$allowed_page = true;
	require_once("../public_html/server/lib/config.php");
	
	mysql_connect(DB_HOSTNAME,DB_USERNAME,DB_PASSWORD) or die("Can not connect to database.Please check your database setting in config file.");
	mysql_select_db(DB_DATABASE_NAME) or die("Can not select database,please check your database setting in config file.");
	mysql_query("SET NAMES 'utf8'");
	while(true)
	{
		// 清除超过10分钟不在线的用户
		$outtimeMax = time()-$outtime;
		
		$sql = "update characters set online = 0 where lastaction<$outtimeMax and online=1";
		mysql_query($sql);
		
		echo "[".date('m-d H:i:s')."] Clear the record which have no any action in 10 min.\n";
		sleep($outtime);
	}

?>